from flask import Blueprint, render_template, redirect, url_for, flash
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user
from flask_login import current_user
from python.extensions import db
from python.model.goods import Goods
from flask import jsonify
main_bp = Blueprint('main', __name__)
menu_bp = Blueprint('menu', __name__, url_prefix='/menu')


@main_bp.route('/')
@login_required
def index():
    return render_template('index.html', username=current_user.username)

@menu_bp.route('/bar_example')
def bar_example():
           return render_template('menu/bar_example.html')



@menu_bp.route('/select_example')
def select_example():
    goods_list=db.session.query(Goods).all()
    test_goods_list=[]
    for good in goods_list:
        test_goods_list.append(
            {
                'a':good.a,
                'b':good.b,
                'c':good.c
            }
        )
    return jsonify(test_goods_list)


